<template>
	<view>
		<view class="header-bar" :class="cixitype ? '':'header-bar-detached'">
			<view class="image" @click="showpopup()">
				<image src="../static/timg/caidan.png" mode=""></image>
			</view>
			<view class="title">首页</view>
		</view>
		<uni-popup ref="popup" type="left">
			<view class="menu">
				<view class="info">
					<view class="infobox">
						<image src="../static/timg/avatar.png" mode=""></image>
						<view class="infoboxright" v-if="userinfos.name">
							<h5>{{userinfos.name}}</h5>
							<view>{{userinfos.level_name}}</view>
						</view>
						<view v-else class="infoboxright" @click="gologin()">
							<view>请登录</view>
						</view>
					</view>
				</view>
				<view class="menu-divider">导航</view>
				<view class="menu-list">
					<view class="menuitem" @click="goSwichPage('/pages/user/profile')">
						<image class="icon" src="../static/icon/1.png" mode=""></image>
						<view>个人资料</view>
						<image class="righticon" src="../static/timg/right1.png" mode=""></image>
					</view>
					<view class="menuitem" @click="goSwichPage('/pages/user/memo')">
						<image class="icon" src="../static/icon/2.png" mode=""></image>
						<view>公告</view>
						<image class="righticon" src="../static/timg/right1.png" mode=""></image>
					</view>
					<view class="menuitem" @click="goSwichPage('/pages/menu/share_friends')">
						<image class="icon" src="../static/icon/3.png" mode=""></image>
						<view>分享好友</view>
						<image class="righticon" src="../static/timg/right1.png" mode=""></image>
					</view>
					<view class="menuitem" @click="goSwichPage('/pages/menu/contact_us')">
						<image class="icon" src="../static/icon/4.png" mode=""></image>
						<view>联系我们</view>
						<image class="righticon" src="../static/timg/right1.png" mode=""></image>
					</view>
					<view class="menuitem" @click="goSwichPage('/pages/menu/my_team')">
						<image class="icon" src="../static/icon/5.png" mode=""></image>
						<view>我的团队</view>
						<image class="righticon" src="../static/timg/right1.png" mode=""></image>
					</view>
					<!-- <view class="menuitem" @click="goSwichPage('/pages/menu/level_history')">
						<image class="icon" src="../static/icon/6.png" mode=""></image>
						<view>合格星级记录</view>
						<image class="righticon" src="../static/timg/right1.png" mode=""></image>
					</view> -->
					<view class="menuitem" @click="goSwichPage('/pages/menu/bind')">
						<image class="icon" src="../static/icon/7.png" mode=""></image>
						<view>绑定</view>
						<image class="righticon" src="../static/timg/right1.png" mode=""></image>
					</view>
					<view class="menuitem" @click="goSwichPage('/pages/menu/report')">
						<image class="icon" src="../static/icon/8.png" mode=""></image>
						<view>报告</view>
						<image class="righticon" src="../static/timg/right1.png" mode=""></image>
					</view>
					<view class="menuitem" @click="goSwichPage('/pages/menu/member_rules')">
						<image class="icon" src="../static/icon/9.png" mode=""></image>
						<view>会员规则须知</view>
						<image class="righticon" src="../static/timg/right1.png" mode=""></image>
					</view>
					<view class="menuitem" @click="goSwichPage('/pages/menu/team_bonus')">
						<image class="icon" src="../static/icon/10.png" mode=""></image>
						<view>团队发展奖金说明</view>
						<image class="righticon" src="../static/timg/right1.png" mode=""></image>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import { getuserinfo } from '../api/api.js'
	export default{
		name: "headerbox",
		props:{
			cixitype:{
				type:Boolean,
				default: false
			}
		},
		data(){
			return{
				islogin:false,
				userinfos:[]
			}
		},
		beforeMount(){
			if(uni.getStorageSync('userinfo')){
				this.userinfos = JSON.parse(uni.getStorageSync('userinfo'))
			}else{
				this.getuserinfofc()
			}
		},
		methods:{
			getuserinfofc(){
				let datas = {
					type:1
				}
				getuserinfo(datas).then(res => {
					if(res.data.status.errorCode == 0){
						this.userinfos = res.data.data.member
					}
				}).catch(err => {
					console.log(err)
				})
			},
			goSwichPage(page){
				this.$refs.popup.close()
				uni.navigateTo({
					url:page
				})
			},
			showpopup(){
				this.$refs.popup.open()
			},
			gologin(){
				uni.navigateTo({
					url:'/pages/login/login'
				})
			}
		}
	}
</script>

<style scoped>
	*{
		box-sizing: border-box;
	}
	.header-bar{
		position: fixed;
		z-index: 98;
		left: 0px;
		right: 0px;
		top: 0px;
		min-height: 110rpx;
		padding: 0px 0px;
		box-shadow: 0 16rpx 48rpx 0 rgba(0, 0, 0, 0.08);
		backdrop-filter: blur(20rpx);
		padding-top: calc((constant(safe-area-inset-top))) !important;
		padding-top: calc((env(safe-area-inset-top))) !important;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		transition: all 250ms ease;
		background-color: rgba(255, 255, 255, 0.85);
	}
	.header-bar-detached{
		border-radius: 40rpx;
		left: 20rpx !important;
		right: 20rpx !important;
		top: 16rpx !important;
		padding-top: 0px !important;
		margin-top: calc(env(safe-area-inset-top)) !important;
		box-shadow: 0 0px 30rpx 0 rgba(0, 0, 0, 0.1) !important;
	}
	.image{
		width: 84rpx;
		height: 84rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.image image{
		width: 32rpx;
		height: 32rpx;
	}
	.title{
		color: #0f1117 !important;
		margin-left: 10rpx;
		flex-grow: 8;
		font-size: 28rpx;
		font-weight: 700;
		text-align: left;
	}
	.menu{
		width: 560rpx;
		height: calc(100vh - 40rpx - env(safe-area-inset-top) - env(safe-area-inset-bottom));
		margin-left: 20rpx;
		margin-top: calc(20rpx + env(safe-area-inset-top));
		overflow-y: scroll;
		background: rgba(255, 255, 255, 0.9);
		box-shadow: 0 -10rpx 10rpx 0 rgba(0, 0, 0, 0.04);
		border-radius: 40rpx !important;
	}
	.info{
		background-color: #FFF !important;
		box-shadow: 0 16rpx 48rpx 0 rgba(0, 0, 0, 0.08) !important;
		border-radius: 40rpx !important;
		margin: 40rpx;
	}
	.infobox{
		width: 100%;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		padding: 20rpx;
	}
	.infobox image{
		width: 90rpx;
		height: 90rpx;
	}
	.infoboxright{
		padding-left: 20rpx;
	}
	.infoboxright h5{
		line-height: 28rpx;
		padding-top: 10rpx;
		padding-left: 10rpx;
		font-size: 32rpx;
		font-weight: 700;
		color: #1b1b1b;
	}
	.infoboxright view{
		line-height: 40rpx;
		padding-left: 10rpx;
		font-size: 22rpx;
		color: #1b1b1b;
	}
	.menu-divider{
		line-height: 48rpx;
		padding-left: 44rpx;
		font-size: 20rpx;
		font-weight: 600;
		color: #6d6d6d;
	}
	.menu-list{
		margin: 0px 20rpx 30rpx 20rpx;
		box-shadow: rgba(0, 0, 0, .35) 0px 30px 60px -30px, rgba(0, 0, 0, .35) 0px -2px 6px 0px inset;
		border-radius: 40rpx !important;
		padding: 20rpx 40rpx;
		display: flex;
		flex-direction: column;
		background-color: #fff;
	}
	.menuitem{
		height: 96rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.menuitem .icon{
		width: 64rpx;
		height: 64rpx;
		border-radius: 50%;
		/* background-image: linear-gradient(to bottom, #5D9CEC, #4A89DC); */
	}
	.menuitem view{
		flex: 1;
		text-align: left;
		padding-left: 26rpx;
		font-size: 26rpx;
		font-weight: 400;
		color: #6d6d6d;
	}
	.righticon{
		width: 20rpx;
		height: 20rpx;
	}
</style>